<?php
namespace app\admin\controller;

use   app\admin\model\Messages as Ma;

class MessageController  extends BaseController{
	public function index(){
		$data=Ma::all(function($query){
			$query->order('id','desc');
		});
		$this->assign([
			'data'=>$data
		]);
		return $this->fetch();
	}
	//删除留言
	public function del(){
		$i=$this->request->param('id');
		if(Ma::destroy($i) ){
			return '删除留言成功!';
		}else{
			return '删除留言失败!';
		}

	}
	//确认查看
	public function show(){
		$i=$this->request->param('id');
		if((new Ma())->allowField(true)->save(['status'=>1],['id'=>$i]) ){
			return '已确认!';
		}else{
			return '已确认!';
		}
	}
}
